package com.hou.houlymall.product.web;

import com.hou.houlymall.product.service.SkuInfoService;
import com.hou.houlymall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * @author H
 * @create 2021-08-12 14:51
 */
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    /**
     * 展示当前sku的详情
     * @param model ...
     * @param skuId ...
     * @return ...
     */
    @GetMapping({"/{skuId}.html"})
    public String skuItem(Model model, @PathVariable Long skuId) throws ExecutionException, InterruptedException {

        SkuItemVo skuItemVo = skuInfoService.item(skuId);

        model.addAttribute("item",skuItemVo);

        return "item";
    }
}
